package com.sinping.qh.domain.auth;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sinping.qh.dto.Insert;
import com.sinping.qh.utils.text.PatternValidator;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author 刘庆沛
 * @since 2017-12-18
 */
@Data
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    /**
     * 唯一主键值 默认是uuid
     */
	@NotBlank(message = "id不能为空",groups = {Insert.class})
	private String id;

	@JsonProperty(value = "user_name")
	@TableField("user_name")
	private String username;

    /**
     * 系统用户默认分配用户昵称
     */
	@JsonProperty(value = "password")
    @TableField("content")
	private String content;
    /**
     * 用户默认昵称
     */
	private String nickname;
    /**
     * 0：正常1：异常
     */
	private Integer status;

	/***
	 * 0:正常 1：删除
	 */
	private Integer deleted;
    /**
     * 数据生成时间 不能为空，数据库自动生成
     */
	@TableField("create_time")
	private Date createTime;
    /**
     * 每次更新自动修改时间
     */
	@TableField("update_time")
	private Date updateTime;

	@JsonProperty(value = "role_name")
	@TableField("role_name")
	private String rolename;

	@Pattern(regexp = PatternValidator.REGEX_PASSWORD_SIMPLE,message = "旧密码格式不正确",groups =  {Insert.class})
	@NotBlank(message = "旧密码不能为空",groups = {Insert.class})
	@JsonProperty(value = "old_password")
	@TableField(exist = false)
	private  String oldContent;

	@Pattern(regexp = PatternValidator.REGEX_PASSWORD_SIMPLE,message = "新密码格式不正确",groups = {Insert.class})
	@NotBlank(message = "新密码不能为空",groups = {Insert.class})
	@JsonProperty(value = "new_password")
	@TableField(exist = false)
	private  String newContent;

	@JsonProperty(value = "role_id")
	@TableField(exist = false)
	private  String roleid;

	@JsonProperty(value = "order_by")
	@TableField(exist = false)
	private  String orderby;

	@Override
	protected Serializable pkVal() {
		return this.id;
	}


}
